using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using WebAndLoadTestPluginsAndRules.Common;

namespace HtmlTagInnerTextTests.Common
{
    /// <summary>
    ///This is a test class for ExactMatchFilterTest and is intended
    ///to contain all ExactMatchFilterTest Unit Tests
    ///</summary>
    [TestClass]
    public class ExactMatchFilterTest
    {
        /// <summary>
        ///A test for Matches
        ///</summary>
        [TestMethod]
        public void Ctor_WhenFilterIsNull_ThrowsArgumentException()
        {
            // Arrange
            const string filter = null;
            const bool ignoreCase = false;

            // Act
            Action action = () => new ExactMatchFilter(filter, ignoreCase);


            // Assert
            AssertHelpers.ThrowsArgumentException<ArgumentException>(action, "filter");
        }

        /// <summary>
        ///A test for Matches
        ///</summary>
        [TestMethod]
        public void Ctor_WhenFilterIsEmpty_ThrowsArgumentException()
        {
            // Arrange
            string filter = string.Empty;
            const bool ignoreCase = false;

            // Act
            Action action = () => new ExactMatchFilter(filter, ignoreCase);


            // Assert
            AssertHelpers.ThrowsArgumentException<ArgumentException>(action, "filter");
        }

        /// <summary>
        ///A test for Matches
        ///</summary>
        [TestMethod]
        public void Matches_WhenValueNull_ReturnsFalse()
        {
            // Arrange
            const string filter = "Test";
            const string value = null;
            const bool ignoreCase = true;
            ExactMatchFilter exactMatchFilter = new ExactMatchFilter(filter, ignoreCase);
            const bool expectedMatches = false;

            // Act
            bool actualMatches = exactMatchFilter.Matches(value);


            // Assert
            Assert.AreEqual(expectedMatches, actualMatches);
        }
        /// <summary>
        ///A test for Matches
        ///</summary>
        [TestMethod]
        public void Matches_WhenCaseInsensitiveAndValueMatchesWithSameCase_ReturnsTrue()
        {
            // Arrange
            const string filter = "Test";
            const string value = "Test";
            const bool ignoreCase = true;
            ExactMatchFilter exactMatchFilter = new ExactMatchFilter(filter, ignoreCase);
            const bool expectedMatches = true;

            // Act
            bool actualMatches = exactMatchFilter.Matches(value);


            // Assert
            Assert.AreEqual(expectedMatches, actualMatches);
        }

        /// <summary>
        ///A test for Matches
        ///</summary>
        [TestMethod]
        public void Matches_WhenCaseInsensitiveAndValueMatchesWithDifferentCase_ReturnsTrue()
        {
            // Arrange
            const string filter = "Test";
            const string value = "TEST";
            const bool ignoreCase = true;
            ExactMatchFilter exactMatchFilter = new ExactMatchFilter(filter, ignoreCase);
            const bool expectedMatches = true;

            // Act
            bool actualMatches = exactMatchFilter.Matches(value);


            // Assert
            Assert.AreEqual(expectedMatches, actualMatches);
        }
        /// <summary>
        ///A test for Matches
        ///</summary>
        [TestMethod]
        public void Matches_WhenCaseInsensitiveAndValueDoesNotMatch_ReturnsFalse()
        {
            // Arrange
            const string filter = "Test";
            const string value = "foo";
            const bool ignoreCase = true;
            ExactMatchFilter exactMatchFilter = new ExactMatchFilter(filter, ignoreCase);
            const bool expectedMatches = false;

            // Act
            bool actualMatches = exactMatchFilter.Matches(value);


            // Assert
            Assert.AreEqual(expectedMatches, actualMatches);
        }



        /// <summary>
        ///A test for Matches
        ///</summary>
        [TestMethod]
        public void Matches_WhenCaseSensitiveAndValueMatchesWithSameCase_ReturnsTrue()
        {
            // Arrange
            const string filter = "Test";
            const string value = "Test";
            const bool ignoreCase = false;
            ExactMatchFilter exactMatchFilter = new ExactMatchFilter(filter, ignoreCase);
            const bool expectedMatches = true;

            // Act
            bool actualMatches = exactMatchFilter.Matches(value);


            // Assert
            Assert.AreEqual(expectedMatches, actualMatches);
        }

        /// <summary>
        ///A test for Matches
        ///</summary>
        [TestMethod]
        public void Matches_WhenCaseSensitiveAndValueMatchesWithDifferentCase_ReturnsFalse()
        {
            // Arrange
            const string filter = "Test";
            const string value = "TEST";
            const bool ignoreCase = false;
            ExactMatchFilter exactMatchFilter = new ExactMatchFilter(filter, ignoreCase);
            const bool expectedMatches = false;

            // Act
            bool actualMatches = exactMatchFilter.Matches(value);


            // Assert
            Assert.AreEqual(expectedMatches, actualMatches);
        }
        /// <summary>
        ///A test for Matches
        ///</summary>
        [TestMethod]
        public void Matches_WhenCaseSensitiveAndValueDoesNotMatch_ReturnsFalse()
        {
            // Arrange
            const string filter = "Test";
            const string value = "foo";
            const bool ignoreCase = false;
            ExactMatchFilter exactMatchFilter = new ExactMatchFilter(filter, ignoreCase);
            const bool expectedMatches = false;

            // Act
            bool actualMatches = exactMatchFilter.Matches(value);


            // Assert
            Assert.AreEqual(expectedMatches, actualMatches);
        }

    }
}